ibm-mq-rs
============

IBM MQ bindings for Rust

This crate provides basic Rust bindings for IBM MQ

```toml
[dependencies]
ibm-mq-rs = "0.1"
```

## Status 🚧
Alpha, this library is currently under development

## Rust version requirements
Works on stable rust

## Building from source
Dependencies
#### IBM MQ libraries
This crate needs to be linked to MQI native libraries. Install IBM MQ client, eg. redistributable client edition. See IBM's [downloads](https://developer.ibm.com/messaging/mq-downloads/) page for details. Set path to MQM lib64 in ibm-mq-sys/.mqlibpath
#### GNU toolchain

```cargo build```


## Usage
IBM MQ C interface is fairly complex and heavy. Crate uses rust builder pattern extensively, but does not try to change basic structure of MQ C API.
Crate uses [failure](https://github.com/rust-lang-nursery/failure) for error handling

### PUT
```rust
    let qm = MQueueManager::connect("QM1", "DEV.APP.SVRCONN", "localhost(1414)", "app", None)?;
    let mut queue = MQueue::builder()
        .queue_mgr(&qm)
        .name("DEV.QUEUE.1")
        .build_queue()?;
    let open_options = MQOpenOpts::builder()
        .with_option(mqi::MQOO_OUTPUT).build();
    queue.open(open_options)?;
    let put_msg_opts = MQPutMsgOpts::builder()
        .with_option(mqi::MQPMO_NO_SYNCPOINT).build();
    for i in 1..10 {
        let msg = MQMessage::from(format!("Hi MQ! - {}", i));
        queue.put(&msg, &put_msg_opts)?;
    } 
    queue.close();
    qm.disconnect();
```

See `tests` folder for other examples

## Features in current version
* MQPUT/MQGET
* Basic PUB/SUB

## ibm-mq-sys
Low level bindings, see `ibm-mq-sys` crate
